<template>
	<div id="app">
		<router-view />
		<BottomTab></BottomTab>
	</div>
</template>

<script>
	import BottomTab from './components/bottom_tab/bottom_tab.vue'
	// import VerifyToken from './utils/verify_token.js'
	import Cookies from 'js-cookie'
	import {
		verify_token_url
	} from "./utils/setting.js"

	export default {
		name: 'App',
		components: {
			BottomTab,
		},
		methods: {

			login_status() {

				
				let user_id = Cookies.get('user_id')
				let token = Cookies.get('token')


				//验证token是否过期
				this.$axios({
					method: 'POST',
					url: verify_token_url,
					data: this.qs.stringify({ //这里是发送给后台的数据
						user_id: user_id,
						token: token
					})
				}).then((response) => { //这里使用了ES6的语法
					// console.log(response) //请求成功返回的数据
					if (response.data.status != 1) {

						Cookies.remove('user_id')
						Cookies.remove('token')

						this.$router.push({
							'name': 'Login'
						})
						this.$message({
							message: "请登录，每12小时后要重新登录一次",
							type: 'error'
						})
					}

				}).catch((error) => {
					// console.log(error) //请求失败返回的数据
					this.$message({
						message: '请联系管理员' + '!!!',
						type: 'error'
					})
				})


			}

		},
		mounted() {
			// console.log(this.$route.path)
			this.login_status()

		}
	}
</script>

<style lang="less">


</style>
